package com.fruitshop.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fruitshop.entity.ProductDetail;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import java.util.List;

/**
 * 商品详情Mapper接口
 */
@Mapper
public interface ProductDetailMapper extends BaseMapper<ProductDetail> {
    
    /**
     * 根据商品ID查询商品详情
     */
    @Select("SELECT * FROM product_detail WHERE product_id = #{productId} AND status = 1 AND deleted = 0")
    ProductDetail findByProductId(Integer productId);
    
    /**
     * 查询热销商品详情列表
     */
    @Select("SELECT * FROM product_detail WHERE status = 1 AND is_hot = 1 AND deleted = 0 ORDER BY sales DESC LIMIT #{limit}")
    List<ProductDetail> findHotProducts(Integer limit);
    
    /**
     * 查询推荐商品详情列表
     */
    @Select("SELECT * FROM product_detail WHERE status = 1 AND is_recommend = 1 AND deleted = 0 ORDER BY sales DESC LIMIT #{limit}")
    List<ProductDetail> findRecommendProducts(Integer limit);
} 